/*
* Conditions Of Use
*
* This software was developed by employees of the Sigmatrix(Beijing) Corporation.
* This software is provided by sigmatrix as a service and is expressly
* provided "AS IS."  Sigmatrix MAKES NO WARRANTY OF ANY KIND, EXPRESS, IMPLIED
* OR STATUTORY, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTY OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT
* AND DATA ACCURACY.  Sigmatrix does not warrant or make any representations
* regarding the use of the software or the results thereof, including but
* not limited to the correctness, accuracy, reliability or usefulness of
* the software.
*
* Permission to use this software is contingent upon your acceptance
* of the terms of this agreement.
*
*/
package com.sigmatrix.h5.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.sigmatrix.h5.dao.DisRebateActivityDetailDao;
import com.sigmatrix.h5.entity.DisRebateActivityDetail;
import com.sigmatrix.h5.service.DisRebateActivityDetailService;
import com.sigmatrix.h5.utils.CommonUtils;
import com.sigmatrix.sc.jdbc.common.service.ServiceImpl;

/**
 *@ClassName: DisRebateActivityDetailServiceImpl
 *@Description: 
 *@author MH
 *@date 2017年8月15日 下午5:51:05
 */
@Service
public class DisRebateActivityDetailServiceImpl extends ServiceImpl<DisRebateActivityDetail,Integer> implements DisRebateActivityDetailService{
	
	@Autowired
	private DisRebateActivityDetailDao disRebateActivityDetailDao;
	
	@Override
	public DisRebateActivityDetail findByDealerIdAndProductId(Integer dealerId, Integer productId){
		final DisRebateActivityDetail po = new DisRebateActivityDetail();
		po.setDealerId(dealerId);
		po.setProductId(productId);
		//根据创建时间倒序排序（ID越大，创建时间越靠后）
		Map<String,String> order = new HashMap<String,String>();
		order.put("id", "desc");
		List<DisRebateActivityDetail> list = disRebateActivityDetailDao.select(po,order);
		return CommonUtils.isEmpty(list)?null:list.get(0);
	}

}
